home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource4 / 258_01 / anyfile.c < prev    next >
Text File  |  1988-03-30  |  640b  |  23 lines

  1.                                          /* Chapter 10 - Program 7 */
  2. #include "stdio.h"
  3.  
  4. main()
  5. {
  6. FILE *fp1;
  7. char oneword[100],filename[25];
  8. char *c;
  9.  
  10.    printf("Enter filename -> ");
  11.    scanf("%s",filename);         /* read the desired filename */
  12.    fp1 = fopen(filename,"r");
  13.  
  14.    do {
  15.       c = fgets(oneword,100,fp1); /* get one line from the file */
  16.       if (c != NULL)
  17.          printf("%s",oneword);    /* display it on the monitor  */
  18.    } while (c != NULL);          /* repeat until NULL          */
  19.  
  20.    fclose(fp1);
  21. }
  22.  
  23.